#include <iostream>

class calculation   //抽象类:具有纯虚函数的类 接口类
//抽象类不能实例化
{
public:
    virtual int calculate(int a,int b)=0;   //纯虚函数
};

//继承自抽象类的类仍然是抽象类，只有重写了纯虚函数才可以实例化
class Add:public calculation
{
    
    virtual int calculate(int a,int b)
    {
        return a+b;
    }
};

class jian:public calculation
{
    
    virtual int calculate(int a,int b)
    {
        return a-b;
    }
};

class Devide:public calculation
{
    
    virtual int calculate(int a,int b)
    {
        return a/b;
    }
};

class Mutiply:public calculation
{
    
    virtual int calculate(int a,int b)
    {
        return a*b;
    }
};



void calculate(calculation *c,int a,int b)
{
    std::cout <<c->calculate(a,b)<<std::endl;
}

int main()
{
    calculate(new Mutiply,1,2);
    return 0;
}